package tests;

import board.Board;
import board.Piece;
import player.Minimax;
import player.Minimax2;
import player.Move;

public class EvalTests {
	public static void main(String[] args){
		testSymmetry();
		testWin();
	}
	
	public static void testSymmetry(){
		//all of these tests should eval to zero because the setups are symmetrical
		
		Board b1 = new Board();
		b1.makeMove(new Move(1,1), Piece.BLACK);
		b1.makeMove(new Move(6,6), Piece.WHITE);
		int i = Minimax2.eval(b1);
		check("Checking symmetrical states", 0, i);
		
		b1.makeMove(new Move(2,2), Piece.BLACK);
		b1.makeMove(new Move(5,5), Piece.WHITE);
		 i = Minimax2.eval(b1);
		 check("Checking symmetrical states", 0, i);
		 b1.makeMove(new Move(5,6), Piece.BLACK);
		 b1.makeMove(new Move(2,1), Piece.WHITE);
		 i = Minimax2.eval(b1);
		 check("Checking symmetrical states", 0, i);
	}
	
	public static void testWin(){
		Board b1 = new Board();
		b1.makeMove(new Move(2,0), Piece.BLACK);
		b1.makeMove(new Move(2,1), Piece.BLACK);
		b1.makeMove(new Move(5,1), Piece.BLACK);
		b1.makeMove(new Move(5,4), Piece.BLACK);
		b1.makeMove(new Move(2,4), Piece.BLACK);
		b1.makeMove(new Move(2,7), Piece.BLACK);
		int i = Minimax2.eval(b1);
		check("Checking winning state for black", -1000, i);
		b1.makeMove(new Move(1,1), Piece.WHITE);
		 i = Minimax2.eval(b1);
		check("Checking winning state for black", -1000, i);
		
		 b1 = new Board();
			b1.makeMove(new Move(0,1), Piece.WHITE);
			b1.makeMove(new Move(1,2), Piece.WHITE);
			b1.makeMove(new Move(3,2), Piece.WHITE);
			b1.makeMove(new Move(4,1), Piece.WHITE);
			b1.makeMove(new Move(6,1), Piece.WHITE);
			b1.makeMove(new Move(7,2), Piece.WHITE);
			i = Minimax2.eval(b1);
			check("Checking winning state for white", 1000, i);
	}
	
	static int count = 0;
	static void check(String test, Object expected, Object result){
		System.out.println(count+": " +test);
		System.out.flush();
		if( expected.equals(result)){
			System.out.println("\tpassed...");
			System.out.flush();
		}
		else{
			try{
				throw new RuntimeException(test+" failed");
			}
			catch(RuntimeException e){
				e.printStackTrace();
			}
		}
		count++;
	}
}
